package net.osweb.core.fw.service;

import java.io.Serializable;

import net.osweb.core.fw.dto.BaseDto;

/**
 * Generic Manager that talks to GenericDao to CRUD POJOs.
 *
 * <p>Extend this interface if you want typesafe (no casting necessary) managers
 * for your domain objects.
 *
 * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
 * @param <T> a type variable
 * @param <PK> the primary key for that type
 */
public interface BaseManager<T, PK extends Serializable> extends GenericManager<T, PK> {

	
	public BaseDto get(BaseDto dto);
	/**
	 * 保存。持久化model，并缓存dto;
	 * 
	 * @param dto
	 */
	public void saveAndCache(BaseDto dto);
	/**
	 * 更新。持久化model，并缓存dto;
	 * 
	 * @param dto
	 */
	public void updateAndCache(BaseDto dto);

	public void remove(BaseDto dto);

	/**
	 * 从缓存中删除
	 * @param dto
	 */
	public void removeFromCache(BaseDto dto);
	
	/**
	 * 替换指定id的缓存dto
	 */
	public void replaceCache(BaseDto newDto);
	
	/**
	 * 抽象方法，由子类实现; model，dto转换
	 * 
	 * @param dto
	 */
	abstract BaseDto trans2Dto(T t);
	abstract T trans2Model(BaseDto dto);
    
}
